// import request from 'umi-request';

import { extend } from 'umi-request';

const request = extend({
  prefix: 'http://localhost:8000',
  timeout: 1000,
  // headers: {
  //   'Content-Type': 'multipart/form-data',
  // },
});

const http = {
  get(url: string, params?: object) {
    return request
      .get(url, {
        params: params,
      })
      .then((res) => {
        return res;
      })
      .catch((error) => {
        console.log(error);
      });
  },
  post(url: string, data?: object) {
    return request
      .post(url, {
        data: data,
      })
      .then((res) => {
        return res;
      })
      .catch(function (error) {
        console.log(error);
      });
  },
};

export default http;
